import React, { Component } from 'react';
import store from './storeRedux/index';
import { connect } from 'react-redux';

class TodoListRedux extends Component {
	constructor(props) {
		super(props);
		this.state = store.getState();
	}

	render() {
			return (
				<div>
					<input
					  value={this.props.inputValue}
						onChange={this.props.handleInputChange}
					/>
					<button>提交</button>
					<ul>
						<li>Dell</li>
					</ul>
				</div>
			)
	}
}



const mapStateToProps = (state) => {
	return {
		inputValue: state.inputValue
	}
}
//store.dispatch 映射到props
const mapDispatchToProps = (dispatch) => {
	return {
		handleInputChange(e) {
			const action = {
				type: 'change_input_value',
				value: e.target.value
			}
			dispatch(action)
		}
	}
}

export default connect(mapStateToProps, mapDispatchToProps)(TodoListRedux);
// export default TodoListRedux;